﻿
namespace Library.OrmEnterpriseEntity.TableInfo {
	///<summary>
	/// Validation exception for Columns
	///</summary>
	public class ValidattionException : TableInfoException {
		/// <summary>
		/// Get columns cause error
		/// </summary>
		public DbColumn[] Columns { get; private set; }
		/// <summary>
		/// Get first column cause error
		/// </summary>
		public DbColumn Column {

			get {
				if (Columns == null || Columns.Length == 0) return null;
				return Columns[0];
			}
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="message">Validation error message</param>
		/// <param name="column">Column causes error in validattion</param>
		public ValidattionException(string message, DbColumn column)
			: this(message, new[] { column }) {
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="message">Validation error message</param>
		/// <param name="columns">Columns cause error in validattion</param>
		public ValidattionException(string message, DbColumn[] columns)
			: base(message) {
			Columns = columns;
		}
	}
}
